<template>
<div>
    <div>
        <van-nav-bar title="选择代申请人员" left-text="返回" left-arrow @click-left="onClickLeft" />
    </div>
    <van-cell-group>
        <van-search v-model="value" placeholder="请输入搜索关键词" input-align="center" @search="onSearch" />
    </van-cell-group>
    <div>
        <!-- <div class="van-coupon" v-for="(item,index) in coupons" :key="index"> -->

        <van-cell-group>
            <van-cell v-for="(item,index) in list" :key="index">
                <van-row>
                    <van-col span="4"><img src="@/assets/user.png" style="width:50px;margin-top:10px" /></van-col>
                    <van-col span="20">
                        <!-- <van-card :num="item" :price="item" desc="描述信息" :title="item" thumb="https://img.yzcdn.cn/vant/ipad.jpeg"> -->

                        <!-- <van-card style="padding-top: 0px;padding-bottom 0px;min-height: 50px; padding-right:0px;">

                            <template #tags>
                                <van-cell :value=item.recordType style="padding-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 5px;">
                                    使用 title 插槽来自定义标题
                                    <img src="@/assets/user.png" />
                                    <template #title>

                                        <van-icon name="user-circle-o" />
                                        <van-tag type="primary" size="large">{{item.userName}}</van-tag>
                                        {{item.sex== "0" ? "女" : "男"}}
                                    </template>
                                    <van-button type="info" size='small' @click="selectClick(item.id,item.userName)">选择</van-button>
                                    <van-tag type="primary" size="large" @click="aaa()">详情</van-tag>
                                </van-cell>
                                <van-cell title='职位' :value=zw(item.identity) styl="padding-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 5px; border-left-width: 10px;" />
                                <van-cell title="邮箱" :value=item.email />
                                <van-cell title="部门" :value=item.organizationName stylt="padding-left: 0px; padding-right: 5px; padding-bottom: 0px;" />
                            </template>
                        </van-card> -->
                        <van-cell @click="selectClick(item.id,item.userName)" style="padding-top: 10px; padding-bottom: 0px; padding-left: 10px; padding-right: 5px;">
                            <h3 style="margin-top: 0px; margin-bottom: -20px;">{{item.userName}} &nbsp;&nbsp;&nbsp;[{{ item.identity==1 ? '事业单位工作人员':'机关工作人员'}}]</h3><br>{{item.organizationName}}
                        </van-cell>
                    </van-col>
                </van-row>
            </van-cell>

        </van-cell-group>

    </div>
</div>
</template>

<script>
import Cookies from 'js-cookie'
export default {
    data() {
        return {
            list: "",
            value: ''
        };
    },
    created() {
        this.cx();
    },
    methods: {
        onClickLeft() {
            this.$router.go(-1);
        },
        zw(data) {
            if (data == 1) {
                return '事业单位工作人员'
            } else if (data == 0) {
                return '机关工作人员'
            }
        },
        zhuanfunction(data) {
            let ret = "";
            for (let it in data) {
                ret +=
                    encodeURIComponent(it) + "=" + encodeURIComponent(data[it]) + "&";
            }
            return ret;
        },
        onSearch(val) {
            this.cx();
        },
        cx() {
            var data = {
                userName: this.value,
                page: 1,
                limit: 9999,
                recordType: 'LEAVE_COMPENSATED'
            };
            const that = this;
            this.$axios({
                headers: {
                    "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "post",
                // url: "user/queryUserListNoLimitPhone",
                url: "user/queryUserList",
                data: this.zhuanfunction(data)
            }).then(response => {
                //这里使用了ES6的语法
                console.log(response); //请求成功返回的数据
                this.list = response.data.data.rows
                console.log(this.list, 66666666666)
            });
        },

        selectClick(id, userName) {
            sessionStorage.setItem('userId', id);
            sessionStorage.setItem('userName', userName);

            // if (this.$route.name) {

            //     this.$router.go(-1);
            // } else {
            //     this.$router.go(-1);
            // }
            this.$router.go(-1);

        }
    }
};
</script>

<style>
</style>
